package com.varian.mybatis.handler;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.RequiredArgsConstructor;
import org.apache.ibatis.reflection.MetaObject;

import java.util.List;

/**
 * @author ben
 * @since 2024/6/23
 */
@RequiredArgsConstructor
public class VarianMetaObjectHandler implements MetaObjectHandler {

    private final List<MybatisMetaObjectHandler> handlers;

    @Override
    public void insertFill(MetaObject metaObject) {
        if (CollUtil.isNotEmpty(handlers)) {
            handlers.forEach(handler -> handler.insertFill(metaObject, this));
        }
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        if (CollUtil.isNotEmpty(handlers)) {
            handlers.forEach(handler -> handler.updateFill(metaObject, this));
        }
    }
}
